class Course:
    """课程领域模型"""
    
    def __init__(self, id=None, name=None, credit=None):
        """初始化Course对象"""
        self.id = id
        self.name = name
        self.credit = credit
        
    def validate(self):
        """验证课程信息的有效性"""
        if not self.name or self.name.strip() == "":
            raise ValueError("课程名称不能为空")
        
        if self.credit is None:
            raise ValueError("课程学分不能为空")
        
        if not isinstance(self.credit, (int, float)):
            raise ValueError("学分必须是数字")
        
        if not (0 <= self.credit <= 10):
            raise ValueError("学分必须在0到10之间")
    
    def __str__(self):
        return f"Course(id={self.id}, name={self.name}, credit={self.credit})"
    
    def __repr__(self):
        return self.__str__()
